package com.devunion.salon.core.dao;

import com.devunion.salon.core.model.security.User;

import javax.persistence.Query;

import org.springframework.transaction.annotation.Transactional;

import java.util.List;

/**
 * @author spetrakovsky
 */
public class UserDao extends AbstractDao<User> {

    public User login(String login, String credentials) {
        List<User> results = jpaTemplate.find("select u from User u where u.loginName = ?", login);
        if (results.size() != 0) {
            User user = results.get(0);
            if (user.getPassword().equals(credentials)) {
                return user;
            }
        }
        return null;
    }

}
